'''
Created on Oct 17, 2012

@author: peng
'''
import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write('cleanup start...')
        arg = self.request.arguments.get('f')
        files = []
        if len(arg) > 0 and arg[0] == 'error':
            files.append('/var/log/collector/error.log')
        if len(arg) > 0 and arg[0] == 'special':
            files.append('/var/log/collector/track-1/special_event.log')
        if len(arg) > 0 and arg[0] == 'routine':
            files.append('/var/log/collector/track-1/routine_event.log')
        for file_path in files:
            f = open(file_path, 'w')
            f.write('')
            f.close()
        self.write('cleanup done!')

application = tornado.web.Application([
                                       (r"/trackcleanup", MainHandler),
                                       ])

if __name__ == '__main__':
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
